package com.franklin.java.action.sql.entity.ui;

import com.franklin.java.icon.EntityIcons;
import com.google.common.collect.Lists;
import com.intellij.icons.AllIcons;
import com.intellij.ui.treeStructure.SimpleNode;

import java.util.Collections;
import java.util.List;

import static com.flychord.jdk.util.tuple.TupleAble.tuple;

/**
 * @author Franklin
 * @since 2021/9/13 15:23
 */
public class ResultNode extends ResultMapChildNode {

    private String property;
    private String column;

    protected ResultNode(SimpleNode aParent, String property, String column) {
        super(aParent);
        this.property = property;
        this.column = column;
        setIcon(AllIcons.Nodes.Field);
        setProperties();
    }

    @Override
    protected void setProperties() {
        this.properties = Lists.newArrayList(
            tuple("property", property),
            tuple("column", column)
        );
    }

    @Override
    public boolean isSingleTag() {
        return true;
    }

    @Override
    public List<String> getChildNodeNames() {
        return Collections.emptyList();
    }

    public static class IdNode extends ResultNode {

        protected IdNode(SimpleNode aParent, String property, String column) {
            super(aParent, property, column);
            setIcon(EntityIcons.Database.pk);
        }
    }
}
